# encoding:utf-8
import logging
import re


def replace_tmpf_fmtval(tempf, dic):
    ret = ""
    with open(tempf, 'r') as fp:
        for line in fp.readlines():
            strfetch = re.findall('\@@.*?@\)', line)
            if strfetch:
                line = line.replace(strfetch, dic[strfetch.lowwer()])
            ret += line
    return ret


class GenLuaf:

    @staticmethod
    def gen_by_template(tempf, tarluaf, dic):
        cont = replace_tmpf_fmtval(tempf, dic)
        with open(tarluaf, "w") as fp:
            fp.write(cont)


__all__ = [
    "GenLuaf"
]
